package com.example.day01;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.day01.contract.LoginContract;
import com.example.day01.model.LoginModel;
import com.example.day01.presenter.LoginPresenter;
import com.example.mvp.view.BaseActivity;

public class LogActivity extends BaseActivity<LoginPresenter> implements LoginContract.LoginView {
    private EditText etName;
    private EditText etPwd;
    private Button btZc;
    private LoginPresenter loginPresenter;



    @Override
    public String getUsername() {
        return etName.getText().toString().trim();
    }

    @Override
    public String getPwd() {
        return etPwd.getText().toString().trim();
    }

    @Override
    public void goMain() {
        Intent intent = new Intent(LogActivity.this, XiaActivity.class);
        startActivity(intent);
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_log;
    }

    @Override
    public void initData() {

    }

    @Override
    public void initView() {
        etName = (EditText) findViewById(R.id.et_name);
        etPwd = (EditText) findViewById(R.id.et_pwd);
        btZc = (Button) findViewById(R.id.bt_zc);

        btZc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loginPresenter.login();
            }
        });

    }

    @Override
    public void inject() {
        loginPresenter = new LoginPresenter(new LoginModel(), this);
    }
}
